package com.itheima.mapper;

import com.itheima.entity.Category;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

public interface CategoryMapper {
    @Insert("insert into category values (null,#{type},#{name},#{sort},#{createTime},#{updateTime},#{createUser},#{updateUser})")
    void save(Category category);

    @Select("select*from category order by sort")
    List<Category> findAll();

    @Delete("delete from category where id=#{id} ")
    void removeById(long id);

    @Delete("delete from category where id=#{id} ")
    void deleteById(long id);

    @Update("update category set type=#{type},name=#{name},sort=#{sort},update_time=#{updateTime},update_user=#{updateUser} where id=#{id} ")
    void updateById(Category category);

    List<Category> list(@Param("type") Integer type);

    @Select("select *from category where id=#{id}")
    Category findById(Long categoryId);

//    void deleteDishByCategoryId(@Param("ids") List<Long> ids);
}
